export * from './RenderComponent'
export * from './DragPointComponent'
export * from './DragComponent'
export * from './DragRectangleComponent'
export * from './RectangleComponent'
export * from './SquareComponent'
export * from './CircleComponent'
export * from './ImageComponent'
export * from './SealComponent'
export * from './SignatureComponent'
import { ComponentType, RenderComponent } from './RenderComponent'
import { SignatureComponent } from './SignatureComponent'
import { SealComponent } from './SealComponent'

const factory:Map<ComponentType, (x: number, y: number) => RenderComponent> = new Map([
  [ComponentType.SEAL, (x: number, y: number) => new SealComponent(x, y)],
  [ComponentType.SIGNATURE, (x: number, y: number) =>  new SignatureComponent(x, y)]
])

export function createComponent(type: ComponentType, x: number, y: number): RenderComponent {
  const component = factory.get(type)?.(x, y);
  if (!component) {
    throw new Error(`Component ${type} not found`);
  }
  return component;
}
